<!-- form 的操作按钮  -->
<template>
  <div>
    <MoreButton>
    <a @click="lookItemHandler" v-btnPermission="'pm_042_loo_01'">查看</a>
    <!-- 拟采取措施-待提交状态 && 当前账号为接收人 -->
    <template v-if="status === 0 && row.isMeasureButton == 1&&hideBuquBtn()">
      <a @click="showModalProposedMeasures">填写拟采取措施</a>
    </template>
    <!-- 拟采取措施-审核中状态 -->
    <template v-if="status === 1">

      <a @click="vapprovInfoeHandler">审批信息</a>
    </template>
    <!-- 拟采取措施-审核通过状态 验证记录-待验收-->
    <template v-if="status === 2">
      <template v-if="row.isRecordButton == 1&&hideBuquBtn()">
        <a @click="showModalAcceptanceRecordStatus">填写验收记录</a>
      </template>
      <a @click="vapprovInfoeHandler">审批信息</a>
    </template>
    <!-- 拟采取措施-审核不通过状态 -->
    <template v-if="status === 3">
      <template v-if="row.isMeasureButton == 1&&hideBuquBtn()">
        <a @click="showModalProposedMeasures">填写拟采取措施</a>
      </template>

      <a @click="vapprovInfoeHandler">审批信息</a>
    </template>
    <!-- 拟采取措施-审核通过状态 验证记录-验收中-->
    <template v-if="status === 4">
      <a @click="vapprovInfoeHandler">审批信息</a>
    </template>
    <!-- 拟采取措施-审核通过状态 验证记录-验收不通过-->
    <template v-if="status === 5">
      <template v-if="row.isRecordButton == 1&&hideBuquBtn()">

        <a @click="showModalAcceptanceRecordStatus">填写验收记录</a>
      </template>

      <a @click="vapprovInfoeHandler">审批信息</a>
    </template>
    <!-- 拟采取措施-审核通过状态 验证记录-验收通过-->
    <template v-if="status === 6">

      <a @click="vapprovInfoeHandler">审批信息</a>
    </template>
    <span v-btnPermission="'pm_042_exp_03'">
      <service-export-mould
        url="/projectCycleEarlyWarn/exportWord"
        :requestParams="{ id: row.id }"
        icon="cloud-download"
        :serviceiUrl="faceApiUrl"
        :isButton="false"
      ></service-export-mould>
    </span>
    </MoreButton>
    <!-- 拟采取措施弹窗 -->
    <a-modal
      title="拟采取措施"
      :closable="false"
      width="1200px"
      :mask-closable="false"
      :footer="null"
      :visible="proposedMeasuresStatus"
      :confirm-loading="confirmLoading"
      @ok="handleOkProposedMeasure"
      @cancel="handleCancelProposedMeasures"
    >
      <ProposedMeasuresCard
        :proposed-measures-status.sync="proposedMeasuresStatus"
        :row="row"
        @showPropseMeasuresPrevInfo="showPropseMeasuresPrevInfo"
        v-on="$listeners"
      />
    </a-modal>

    <!-- 验收记录弹窗 -->
    <a-modal
      title="验收记录"
      :closable="false"
      width="1200px"
      :mask-closable="false"
      :footer="null"
      :visible="acceptanceRecordStatus"
      :confirm-loading="confirmLoading"
      @ok="handleOkProposedMeasure"
      @cancel="handleCancelProposedMeasures"
    >
      <AcceptanceRecordCard
        :acceptance-record-status.sync="acceptanceRecordStatus"
        :row="row"
        v-on="$listeners"
      />
    </a-modal>
  </div>
</template>

<script>
import mixins from '../mixins.js'
import ProposedMeasuresCard from './ProposedMeasuresCard'
import AcceptanceRecordCard from './AcceptanceRecordCard'
import ServiceExportMould from '@/components/ServiceExportMould'
import { faceApiUrl } from '@/api/config.js'
import { getProjectCycleEarlyWarnById } from '@/api/project/warning'
export default {
  name: 'Opera',
  props: ['row'],
  mixins: [mixins],
  data() {
    return {
      faceApiUrl: faceApiUrl,
      confirmLoading: false,
      proposedMeasuresStatus: false, // 拟采取措施弹窗
      acceptanceRecordStatus: false // 验收记录弹窗
    }
  },

  components: { ProposedMeasuresCard, AcceptanceRecordCard, ServiceExportMould },

  computed: {
    status() {
      return this.handlerOperaBtns(this.row)
    }
  },

  mounted() {},

  methods: {
    // 拟采取不通过的，点击填写 回显上一次的信息
    showPropseMeasuresPrevInfo(cb) {
      getProjectCycleEarlyWarnById({ id: this.row.id }).then((res) => {
        cb(res.data)
      })
    },
    handleOkProposedMeasure() {},
    // 点击审批信息
    vapprovInfoeHandler() {
      this.$emit('approveHandler', this.row)
    },
    // 拟采取措施弹出
    showModalProposedMeasures() {
      this.proposedMeasuresStatus = true
    },
    // 验收记录弹出
    showModalAcceptanceRecordStatus() {
      this.acceptanceRecordStatus = true
    },
    // 弹窗关闭
    handleCancelProposedMeasures() {
      this.proposedMeasuresStatus = false
      this.acceptanceRecordStatus = false
    },
    // 查看
    lookItemHandler() {
      this.$router.push({
        path: '/project/look',
        query: {
          _id: this.row.id
        }
      })
    }
  }
}
</script>
<style lang='less' scoped>
</style>
